// string
package main
import(
	"fmt"
	"unsafe"
	"strconv"
)
func main(){
	var char int = 'f'
	var age int64 = 60
	var price float32 = 141.45100
	//var address string = "浦建路1143号"
	var isMarried bool = true
	var floatAge float32 = float32(age)
	fmt.Printf("char's value is %d \n",char)
	fmt.Printf("my age is %d,occupy %d bytes \n",age,unsafe.Sizeof(age))
	fmt.Printf("floatAge is %f \n",floatAge)
	var priceStr = fmt.Sprintf("%f",price)
	fmt.Printf("priceStr = %q \n",priceStr)

	/****************************************************/
	var ageStr1 = strconv.FormatInt(age,10)
	var marriedStr = strconv.FormatBool(isMarried)
	var priceStr1 = strconv.FormatFloat(float64(price),'f',-1,64) //参数：格式 精度 来源类型
	fmt.Printf("Ryan's age is %v,his isMarried is %v,his house's price is %v \n",ageStr1,marriedStr,priceStr1)
	
	var age1,_ = strconv.ParseInt(ageStr1,10,0)
	var isMarried1,_ = strconv.ParseBool(marriedStr)
	var price1,_ = strconv.ParseFloat(priceStr1,32) //字符串转float，不需要考虑格式
	fmt.Printf("age1 is %d type %T , isMarried is %t type %T , price1 is %f type %T\n",age1,age1,isMarried1,
		isMarried1,price1,price1)

	var newInt,_ = strconv.ParseInt("true",10,8) //字符串默认转成0
	fmt.Printf("new string is %d \n",newInt)
}